package cn.kgc.mybatis.dao;

import cn.kgc.mybatis.entity.Student;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 *
 *使用注解实现学生信息的增删改
 * @author mosin
 * date 2021/11/3
 * @version 1.0
 */
public interface StudentDao {
    @Select("select * from student")
    List<Student> findAll();

    @Select("select * from student where id = #{id}")
    @Results({
        @Result(property = "name",column = "stu_name")
    })
    Student findOne(Integer id);

    @Update("update student set stu_name = #{name},stu_no=#{stuNo},stu_sex=#{stuSex},stu_birth=#{stuBirth} where id = #{id}")
    Integer updateStudent(Student student);

    @Delete("delete from student where id = #{id}")
    Integer deleteStudents(Integer id);

    @Insert("insert into student(stu_name,stu_no,stu_sex,stu_birth)values(#{name},#{stuNo},#{stuSex},#{stuBirth}) ")
    Integer addStudent(Student student);

}
